<?php

/**
 * Campaign form base class.
 *
 * @method Campaign getObject() Returns the current form's model object
 *
 * @package    ecrm
 * @subpackage form
 * @author     Saul Santiago
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseCampaignForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                      => new sfWidgetFormInputHidden(),
      'name'                    => new sfWidgetFormInputText(),
      'site_url'                => new sfWidgetFormInputText(),
      'start_date'              => new sfWidgetFormDateTime(),
      'end_date'                => new sfWidgetFormDateTime(),
      'contant_information_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ContantInformation'), 'add_empty' => true)),
      'personal_information_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('PersonalInformation'), 'add_empty' => true)),
      'company_information_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CompanyInformation'), 'add_empty' => true)),
      'message'                 => new sfWidgetFormInputText(),
      'database_source_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('DatabaseSource'), 'add_empty' => true)),
      'kind_of_campaign'        => new sfWidgetFormInputText(),
      'created_at'              => new sfWidgetFormDateTime(),
      'updated_at'              => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                      => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'name'                    => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'site_url'                => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'start_date'              => new sfValidatorDateTime(array('required' => false)),
      'end_date'                => new sfValidatorDateTime(array('required' => false)),
      'contant_information_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('ContantInformation'), 'required' => false)),
      'personal_information_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('PersonalInformation'), 'required' => false)),
      'company_information_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('CompanyInformation'), 'required' => false)),
      'message'                 => new sfValidatorPass(array('required' => false)),
      'database_source_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('DatabaseSource'), 'required' => false)),
      'kind_of_campaign'        => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'created_at'              => new sfValidatorDateTime(),
      'updated_at'              => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('campaign[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Campaign';
  }

}
